﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuanLyDoiXe.Lop_du_lieu;

namespace QuanLyDoiXe.lop_doi_tuong
{
    class lop_phancong
    {
        string Mxe,NNVPC,Mtaixe;
        DateTime NgayPC;
        DateTime Thoigianbatdau,Thoigianketthuc;
        public lop_phancong(){}
        public lop_phancong(string Mxe, string NNVPC,string Mtaixe,DateTime NgayPC,DateTime Thoigianbatdau,DateTime Thoigianketthuc)
        {
            this.Mxe = Mxe;
            this.Mtaixe = Mtaixe;
            this.NNVPC = NNVPC;
            this.NgayPC = NgayPC;
            this.Thoigianbatdau = Thoigianbatdau;
            this.Thoigianketthuc = Thoigianketthuc;
        }
        #region các thủ tục SET
        public void set_maxe(string Mxe)
        {
            this.Mxe = Mxe;
        }
        public void set_MNVPC(string NNVPC)
        {
            this.NNVPC = NNVPC;
        }
        public void Set_Mtaixe(string Mtaixe)
        {
            this.Mtaixe = Mtaixe; ;
        }
        public void set_NgayPC(DateTime NgayPC)
        {
            this.NgayPC = NgayPC;
        }
        public void set_Thoigianbatdau(DateTime Thoigianbatdau)
        {
            this.Thoigianbatdau = Thoigianbatdau;
        }
        public void set_Thoigianketthuc(DateTime Thoigianketthuc)
        {
            this.Thoigianketthuc = Thoigianketthuc;
        }
        #endregion
        #region Các phương thức hoạt động
        public bool taomoi()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("insert into phancon(Mxe,Mtaixe,NNVPC,NgayPC,Thoigianbatdau,Thoigianketthuc) values ('" + Mxe + "',N'" + Mtaixe + "','" + NNVPC + "',N'" + NgayPC + "','" + Thoigianbatdau + "','" + Thoigianketthuc + "')") == 1)
            {
               lop_ket_noi.huyketnoi();
               return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool capnhat()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("update phancon set Mtaixe = N'" + Mtaixe + "',NNVPC = '" + NNVPC + "',NgayPC = '" + NgayPC + "',Thoigianbatdau='" + Thoigianbatdau + "',Thoigianketthuc='" + Thoigianketthuc + "' where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool xoa()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if (dl.thucthitruyvan("delete from phancon where Mxe='" + Mxe + "'") == 1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        public bool tiepnhan()
        {
            Lop_lay_du_lieu dl = new Lop_lay_du_lieu();
            if(dl.thucthitruyvan("update phancon set Mtaixe = N'"+ Mtaixe + "', NNVPC =N '"+ NNVPC +"',NgayPC='"+NgayPC+"',Thoigianbatdau='"+Thoigianbatdau+"',Thoigianketthuc='"+Thoigianketthuc+"' where Mxe='" + Mxe + "'")==1)
            {
                lop_ket_noi.huyketnoi();
                return true;
            }
            else
            {
                lop_ket_noi.huyketnoi();
                return false;
            }
        }
        #endregion
    }
}
